package tq.com.tqteacher.mine.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import tq.com.systools.system.AlertDialogHelper;
import tq.com.systools.system.StringHelper;
import tq.com.tqcom.base.BaseFragment;
import tq.com.tqcom.net.INetCallback;
import tq.com.tqcom.net.TQNetResult;
import tq.com.tqteacher.R;
import tq.com.tqteacher.model.TQLogin;
import tq.com.tqteacher.net.TQNetInterface;
import tq.com.tqteacher.propertyEnum.TQModify;

public class TQTeacherIntrFragment extends BaseFragment {
    private EditText mEditText;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View lView = inflater.inflate(R.layout.fragment_teacherinfo_layout, container, false);
        mEditText = lView.findViewById(R.id.content);
        return lView;
    }

    public void submit(){
        String content = StringHelper.editText(mEditText);

        TQNetInterface.modifyTeacherInfo(TQLogin.getCurrent().getUserInfo().getId(),TQModify.TeacherInfo.intro, content, new INetCallback() {
            @Override
            public void result(TQNetResult pNetResult) {
                if(pNetResult.isSuccess()){
                    getActivity().finish();
                }else{
                    AlertDialogHelper.show(getContext(), pNetResult.getErrMsg());
                }
            }
        });
    }
}
